﻿using System;
using System.Collections.Generic;
using System.Windows;

namespace Utils
{
	public static class Math2
	{
		public static double CalculateHypotenuse(double x, double y)
		{
			return Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2));
		}

		public static double CalculateLength(IEnumerable<Point> function)
		{
			double result = 0;
			Point? previousPoint = null;

			foreach (Point point in function)
			{
				if (previousPoint == null)
				{
					previousPoint = point;
				}
				else
				{
					result = result + Math2.CalculateHypotenuse(point.X - previousPoint.Value.X, point.Y - previousPoint.Value.Y);
					previousPoint = point;
				}
			}

			return result;
		}
	}
}
